import http from '@http';

const API_PREFIX = 'monitor/cache';

/**
 * 获取缓存信息
 *
 * @returns {Promise<AxiosResponse<any>>}
 */
export function fetchGetCacheInfo() {
  return http.get(API_PREFIX + '/info');
}

/**
 * 获取缓存名称列表
 *
 * @param values
 * @returns {Promise<AxiosResponse<any>>}
 */
export function fetchGetCacheNames(values = {}) {
  return http.get(API_PREFIX + '/names', values);
}

/**
 * 获取缓存数据
 *
 * @param {Object} cache
 * @returns {Promise<AxiosResponse<any>>}
 */
export function fetchGetCacheKeys(cache) {
  return http.post(API_PREFIX + '/keys', cache);
}

/**
 * 获取缓存数据详情
 *
 * @param cacheKey
 * @returns {Promise<AxiosResponse<any>>}
 */
export function fetchGetCacheValue(cacheKey) {
  return http.get(API_PREFIX + '/detail/' + cacheKey);
}

/**
 * 清除缓存数据
 * @param cacheKey
 * @returns {Promise<AxiosResponse<any>>}
 */
export function fetchClearCacheKey(cacheKey) {
  return http.get(API_PREFIX + '/clear/key_' + cacheKey);
}

/**
 * 清除缓存名称
 * @param cacheName
 * @returns {Promise<AxiosResponse<any>>}
 */
export function fetchClearCacheName(cacheName) {
  return http.get(API_PREFIX + '/clear/name_' + cacheName);
}
